#include "fig_bullet_sfx.h"
#include "fig_sfx_manager.h"



FIGBulletSfx::FIGBulletSfx(float Speed, 
						   FIGSfx::SFX_TYPES	SfxType 
						   ) :	FIGBullet(	Speed,
											false,
											1.0f,
											FIGBullet::BULLET_TYPE_EFFECT_FIRE
											),
											m_pSfx(NULL),
											m_SfxType(SfxType)											
{
	m_Radius = 0.025f;	
	m_Howlong = m_Radius * 10;
}




void		FIGBulletSfx::Tick(float dt)
{
	

	FIGBullet::Tick(dt);
	if(m_pSfx && m_IsAlive)
		m_pSfx->FollowMe(m_Pos );

	if(!m_IsAlive &&  m_pSfx)
	{
		m_pSfx->ToDie();
		m_pSfx = NULL;
	}
}

void		FIGBulletSfx::ReSpawn(const math::Vec2& Pos,
								FIGBullet::STARTPOS StartDir,
								const math::Vec2& TargetDir
								)
{
	FIGBullet::ReSpawn(Pos,StartDir,TargetDir);
	m_pSfx = FIGSFXManager::Instance().Spawn(m_SfxType,Pos,1.0f,0);
	//m_pSfx->SetRotation(m_Rotation + 18.0f);
}

void		FIGBulletSfx::Kill() 
{ 
	FIGBullet::Kill();
	if(m_pSfx)
	{
		m_pSfx->ToDie();
		m_pSfx = NULL;
	}
	
};


/*
std::string		FIGBulletSfx::GetSfxNameByType(FIGBullet::BULLET_TYPES Type)
{
	return "";
}
*/